" 配色方案
colorscheme oceandeep

" 设置编码和文件格式
set fileencoding=utf-8
set fileformats=unix,dos

" 使用 vim 设置，比使用 vi 设置更好
" 这个选项必须在一开始就设置，因为可能会影响到其他选项
set nocompatible

" 设置 <leader> 为 ","
let mapleader=","

" 允许退格键在插入模式下删除所有东西
set backspace=indent,eol,start

" 不保存备份文件
set nobackup

" 命令行存储在历史中的条数
set history=50

" 在最后一行显示部分的命令
set showcmd

" 搜索时高亮匹配的字符串
set incsearch

" 搜索时只有在搜索的字符串都为小写时才忽略大小写
set smartcase

" 在所有模式中允许使用鼠标
if has('mouse')
	set mouse=a
endif


if &t_Co > 2 || has("gui_running")
	" 设置高亮
	syntax on

	" 高亮搜索到的匹配字符串
	set hlsearch
endif

if has("autocmd")
	" 允许文件类型检测
	filetype plugin indent on

	" Put these in an autocmd group, so that we can delete them easily.
	augroup vimrcEx
	au!

	" For all text files set 'textwidth' to 78 characters.
	autocmd FileType text setlocal textwidth=78

	" When editing a file, always jump to the last known cursor position.
	" Don't do it when the position is invalid or when inside an event handler
	" (happens when dropping a file on gvim).
	" Also don't do it when the mark is in the first line, that is the default
	" position when opening a file.
	autocmd BufReadPost *
		\ if line("'\"") > 1 && line("'\"") <= line("$") |
		\   exe "normal! g`\"" |
		\ endif

	augroup END

else
	" 继承前一行的缩进方式，特别适用于多行注释
	set autoindent
endif

" 载入 msvin.vim 配置
source $VIMRUNTIME/mswin.vim

" 显示行号
set nu

" 为 c 程序提供自动缩进
set smartindent

" 设置 c 的缩进方式
set cindent

" 制表符为 4
set tabstop=4

" 统一缩进为 4
set softtabstop=4
set shiftwidth=4

" 不要用空格代替制表符
set noexpandtab

" 设置界面高宽相应的行数
set lines=26
set columns=100

" 高亮当前行
if has("gui_running")
	set cursorline
	"set cursorcolumn
	hi cursorline guibg=#112233
	"hi CursorColumn guibg=#446688
endif

" 显示和隐藏菜单栏、工具栏
set guioptions-=T
set guioptions-=m
map <silent> <F4> :if &guioptions=~# 'T'<Bar>
		\set guioptions-=T<Bar>
		\set guioptions-=m<Bar>
		\else <Bar>
		\set guioptions+=T<Bar>
		\set guioptions+=m<Bar>
		\endif<CR>	"快捷键

" 状态栏的显示
set laststatus=2
set statusline=\ %f%m%r%h%w\ \[%{&fileformat}\\%{&fileencoding}\]\ %=\ Line:%l/%L:%c\ """" CWD:%{CurDir()}\ %=\ Line:%l/%L:%c\ 
"function! CurDir()
"	let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
"	return curdir
"endfunction

" 使用 <space> 来打开和关闭折叠
nnoremap <space> @=((foldclosed(line('.'))<0) ? 'zc' : 'zo')<cr>	"快捷键

" 生成 cscope 和 ctags 文件
set cscopequickfix=s-,c-,d-,i-,t-,e-
cs add cscope.out
set tags=tags;
if exists("&autochdir")
	set autochdir
endif
map <F2> :call CscopeAndCtags()<cr>	"快捷键
function! CscopeAndCtags()
	exec "w"
	exec "!cscope -Rbq"
	exec "!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ."
	exec "cs add cscope.out"
endfunction

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" 键盘映射-设置快捷键 "快捷键
" 上下选择自动补全选项
inoremap <expr> <C-j> pumvisible()?"<C-n>":"<C-x><C-o>"
inoremap <expr> <C-k> pumvisible()?"<C-p>":"<C-k>"

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" 判断系统
function! MySys()
	if has("win32")
		return "windows"
	else
		return "linux"
	endif
endfunction

if MySys() == "linux"
	set tags+=~/Documents/tags/c++.4.4.tags,~/Documents/tags/qt.3.2.1.tags
endif

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Taglist 插件
let Tlist_Show_One_File = 1
let Tlist_Exit_OnlyWindow = 1
let Tlist_Use_Right_Window = 1
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_WinWidth = 25
map <leader>tl :TlistToggle<cr>	"快捷键

" NERD_Tree 插件
let NERDTreeWinSize = 25
let NERDTreeQuitOnOpen = 1
map <leader>nt :NERDTree<cr>	"快捷键
"map <leader>nc :NERDTreeClose<cr>	"快捷键

" omnicppcomplete 插件
let OmniCpp_MayCompleteScope = 1

" fencview 插件
let g:fencview_auto_patterns='*.cnx,*.txt,*.html,*.php,*.cpp,*.h,*.c,*.css,*.java{|\=}'

" bufexplorer 插件
map <leader><leader> <leader>be	"快捷键

" DoxygenToolkit 插件
let g:DoxygenToolkit_authorName="jKeyLu@qq.com"

" acomment 插件
" 过度匹配注释模式，注释符号中间的空白字符不可忽略
let g:acommentStrictMode=2
" 自定义头部注释
function g:acommentSet()
	let g:acomment={}
	let g:acomment['user']='jKeyLu@qq.com'
	let g:acomment['cTop']=[
			\ [["@file ",'Y'],[expand("%"),'N']]
			\,[["@brief ",'N'],["",'Y']]
			\,[["@author ",'Y'],[g:acomment["user"],'T']]
			\,[["@data ",'Y'],[strftime("%Y-%m-%d %H:%M:%S"),'T']]
			\,[["@modifier ",'Y'],[g:acomment["user"],'SIGN']]
			\,[["@modified ",'Y'],[strftime("%Y-%m-%d %H:%M:%S"),'N']]
			\]
endfunction

